<script type="text/javascript">
 $(function() {
	$("select[name='dm']").change(function(){
		$("form#frm_dm").submit();
	});
 });
 </script>
 <link type="text/css" rel="stylesheet" href="css/services.css"/>
 <style type="text/css">
 
#content-right, #info {
    clear: both;
}
#content-right {
    margin: 0 auto;
    width: 820px;
}
.type1 {
    float: none;
}

.filter{
    width: 200px;
    height: 28px;
    overflow: hidden;
    background: url("images/dropdown.png") no-repeat right #ddd;
    border: 0;
    float: left;
	margin:3px;
}

.filter select{
    background: transparent;
    width: 225px;
    line-height: 1;
    padding: 5px;
    border: none;
    border-radius: 1px;
    -webkit-appearance: none;
}

#frm_dm{
    margin-top: 50px;
}
#add_new{
	clear: right;
    float: right;
    position: relative;
    right: 100px;
    top: -20px;
}
 </style>
		<h1>Dịch vụ</h1>
		<?php echo form_open(current_url(),"id='frm_dm'"); ?>
                <div style="margin: 0px auto; width: 320px;">
                <span style="display:inline; margin-top: 5px; position: relative; float: left;">Loc theo:</span>
                <div class="filter">
                <?php echo $combobox_cats;?>
                </div>
                    </div>
					<div id="add_new">
				<?php  
                    if( isset( $action )){
                        foreach($action as $a){
                            if( strtolower($a['id']) == 'new'){
                                echo anchor( base_url( ) . $a['url'], $a['label'] );
                                break;
                            }
                        }
                    } 
                        
                ?>
				</div>
                <br style="clear:both;" />
<?php echo form_close(); ?>
		<div id = "top_reserve">
			<div id = "content-right">
			
			
		</div>
		<div class="type1" id="content-right">
<table >
	<tr>
            <?php
            foreach ($rules as $i) {
                if (in_array($i['field_id'], $master_limited)) {
                    if (isset($i['width']))
                        $width = "width = '" . $i['width'] . "'";
                    else
                        $width = "";
                    echo "<th $width class='".$i['class']."' style='".$i['style']."'>" . $i['html'] . "</th>";
                }
            }
            ?>
            <th class="last">Action</th>
	</tr>
	 <?php
                for( $i = 0; $i < count( $results ); $i++ ){
				if($i%2==1) $odd="odd"; else $odd="";
                    echo "<tr class='$odd'>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	        
         			                echo "<td>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else if($item[ 'control' ] == "percent") 
										echo $results[ $i ][ $item[ 'field_id' ] ]."%";
									else echo $results[ $i ][ $item[ 'field_id' ] ];
            						echo "</td>";					
    					}?>
                         
                        <?php 
                            }
                        echo "<td>";
                            if( isset( $action ) ){
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'edit'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'delete'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                            }
                      
                            if( isset( $custom_action ) ){
                                
                                foreach( $custom_action as $item ){
                                //    $a = explode( '=', $item );
                                //    if( isset( $a[ 0 ] ) )
                                        echo $results[$i][$item['action_name']]. "  ";
                                }
                            }
                        echo "</td>";
                    echo "</tr>";
                }
            ?>
			<tr><td colspan="<?php echo count($rules) +1;?>"><center><div class="pagination"><?php echo $this->pagination->create_links(); ?></div></center></td></tr>
	</table>
</div>
</div>

